package com.huawei.appmarket;

import android.annotation.TargetApi;
import android.app.Activity;
import android.content.Context;
import android.content.IntentFilter;
import android.os.Bundle;
import android.view.Menu;
import android.view.View;
import android.widget.ImageView;
import androidx.annotation.NonNull;
import com.huawei.appgallery.foundation.account.bean.UserSession;
import com.huawei.appgallery.foundation.ui.framework.cardframe.bean.BaseCardBean;
import com.huawei.appgallery.foundation.ui.framework.cardframe.fragment.TaskFragment;
import com.huawei.appgallery.foundation.ui.framework.cardframe.fragment.TaskFragment.b;
import com.huawei.appgallery.serverreqkit.api.bean.ResponseBean;
import com.huawei.appgallery.serverreqkit.api.bean.ResponseBean.a;
import com.huawei.appgallery.serverreqkit.api.bean.startup.StartupResponse;
import com.huawei.appgallery.serverreqkit.api.listener.IServerCallBack;
import com.huawei.appmarket.framework.MainActivityBase;
import com.huawei.appmarket.framework.fragment.AppCenterStartUpLoadingFragment;
import com.huawei.appmarket.framework.startevents.bean.CountryInfo;
import com.huawei.appmarket.framework.startevents.protocol.ServiceZoneSwitchActivityProtocol;
import com.huawei.appmarket.framework.startevents.protocol.ServiceZoneSwitchActivityProtocol.Request;
import com.huawei.appmarket.framework.startevents.roam.RoamActivity;
import com.huawei.appmarket.service.appdetail.bean.report.GeneralResponse;
import com.huawei.appmarket.service.appdetail.bean.report.GeneralResponse.GradeInfo;
import com.huawei.appmarket.service.appdetail.bean.report.GeneralResponse.ListNumStyle;
import com.huawei.appmarket.service.appdetail.bean.report.GeneralResponse.OpenWishWall;
import com.huawei.appmarket.service.appdetail.bean.report.GeneralResponse.OpenWishWallData;
import com.huawei.appmarket.service.appdetail.bean.report.GeneralResponse.ThirdInstallSwitch;
import com.huawei.appmarket.service.appdetail.bean.report.GeneralResponse.ThirdInstallSwitchData;
import com.huawei.appmarket.service.common.protocol.AppActivityProtocol;
import com.huawei.appmarket.service.plugin.receiver.CommonActivityReceiver;
import com.huawei.appmarket.support.widget.tabhost.FragmentTabHost;
import huawei.widget.HwBottomNavigationView;
import java.util.List;
import o.AccountBussinessListener;
import o.ccp;
import o.ceh;
import o.PermissionChecker;
import o.cfw;
import o.cia;
import o.cjk;
import o.cjm;
import o.cjo;
import o.cju;
import o.ckm;
import o.cuh;
import o.cvt;
import o.BaseRequest;
import o.dgh;
import o.dgm;
import o.dil;
import o.RoamDataManager;
import o.dji;
import o.djp;
import o.dmi;
import o.dmn;
import o.dmp;
import o.dmq;
import o.dmr;
import o.Logger;
import o.dof;
import o.ContentManager;
import o.drh;
import o.dte;
import o.dxe;
import o.dzt;
import o.dzu;
import o.dzv;
import o.dzy;
import o.InteractiveRecommListener;
import o.ebc;
import o.ebf;
import o.ebi;
import o.InteractiveRecommListenerImpl;
import o.egv;
import o.eiu;
import o.emw;
import o.enc;
import o.eny;
import o.eod;
import o.eoj;
import o.eox;
import o.CollectCheck;
import o.NetWorkUtls;
import o.eua;
import o.euf;
import o.ActivityUtil;
import o.evk;
import o.VideoNetChangeDialog;

public class MarketActivity extends MainActivityBase<AppActivityProtocol> implements ceh, com.huawei.appmarket.framework.widget.ColumnNavigator.e, InteractiveRecommListener, ebf {
    private CommonActivityReceiver ʾ;
    private long ʿ;
    private InteractiveRecommListenerImpl ˉ;
    private AccountBussinessListener mAccountListener = new InnerAcountBusListner();
    protected NetWorkUtls mNetWorkUtils;

    static class InnerAcountBusListner implements AccountBussinessListener {
        private InnerAcountBusListner() {
        }

        public void onAccountBusinessResult(ccp o_ccp) {
            Logger.ˎ("MarketActivity", "mustLogin() onAccountBusinessResult accountResult.resultCode=" + o_ccp.ˎ);
            if (102 != o_ccp.ˎ) {
                dzv.ˊ();
            }
            eoj.ˋ().ˊ("forceLogin");
        }
    }

    static class d implements IServerCallBack {
        private d() {
        }

        public void prePostResult(BaseRequest o_cvu, ResponseBean responseBean) {
            if ((responseBean instanceof GeneralResponse) && (o_cvu instanceof drh) && responseBean.getResponseCode() == 0 && responseBean.getRtnCode_() == 0) {
                ˋ(o_cvu, responseBean);
            }
        }

        public void notifyResult(BaseRequest o_cvu, ResponseBean responseBean) {
            if ((responseBean instanceof GeneralResponse) && responseBean.getResponseCode() == 0) {
                GeneralResponse generalResponse = (GeneralResponse) responseBean;
                if (generalResponse.getRtnCode_() == 0) {
                    GradeInfo ॱॱ = generalResponse.ॱॱ();
                    if (ॱॱ != null && ॱॱ.ˏ() != null && !CollectCheck.isEmpty(ॱॱ.ˏ().ॱ())) {
                        Logger.ˎ("MarketActivity", "[global]  gradeInfo != null");
                        dzy.ॱ(ॱॱ);
                    }
                }
            }
        }

        private void ˋ(BaseRequest o_cvu, ResponseBean responseBean) {
            GeneralResponse generalResponse = (GeneralResponse) responseBean;
            CountryInfo ʻ = generalResponse.ʻ();
            if (ʻ != null) {
                List ˋ = ʻ.ˋ();
                if (CollectCheck.isEmpty(ˋ)) {
                    Logger.e("MarketActivity", "Global countryData is null");
                } else {
                    dzu.ॱ(ˋ, ((drh) o_cvu).getServiceType_());
                }
            } else {
                Logger.e("MarketActivity", "Global countryInfo is null");
            }
            ThirdInstallSwitch ˎ = generalResponse.ˎ();
            if (ˎ != null) {
                ThirdInstallSwitchData ˏ = ˎ.ˏ();
                if (ˏ != null) {
                    ebc.ˊ().ˋ(ˏ.ˎ());
                }
            }
            ˊ(generalResponse);
            ˎ(generalResponse);
        }

        private void ˊ(GeneralResponse generalResponse) {
            OpenWishWall ʽ = generalResponse.ʽ();
            if (ʽ != null) {
                OpenWishWallData ˋ = ʽ.ˋ();
                if (ˋ != null) {
                    eny.ˊ().ˏ(ˋ.ˎ());
                }
            }
        }

        private void ˎ(GeneralResponse generalResponse) {
            ListNumStyle ʼ = generalResponse.ʼ();
            if (ʼ != null) {
                List ˏ = ʼ.ˏ();
                if (ˏ != null) {
                    eiu.ˏ().ˏ(ˏ);
                }
            }
        }
    }

    static class e implements dmi {
        private e() {
        }

        public void run() {
            cvt o_drh = new drh("grade,supportCountry,thirdInstall,openWishWall,listNumStyle");
            if (egv.ॱᐝ().ॱˋ()) {
                String ʿ = egv.ॱᐝ().ʿ();
                if (!dof.ˋ(ʿ) && ʿ.split("\\|").length == 3) {
                    try {
                        String str = ʿ.split("\\|")[1];
                        ʿ = ʿ.split("\\|")[2];
                        o_drh.setGradeLevel_(Integer.parseInt(str));
                        o_drh.setGradeType_(ʿ);
                    } catch (NumberFormatException e) {
                        Logger.ˋ("MarketActivity", "NumberFormatException!");
                    }
                }
            }
            cfw.ˎ(o_drh, new d());
        }
    }

    public void onCreate(Bundle bundle) {
        dgm.ˋ(0, this, R.string.app_name, null);
        AppActivityProtocol appActivityProtocol = (AppActivityProtocol) ʾ();
        if (!(appActivityProtocol == null || appActivityProtocol.ˋ() == null)) {
            this.ᐝॱ = ((AppActivityProtocol) ʾ()).ˋ().ˊ();
            this.ʻॱ = ((AppActivityProtocol) ʾ()).ˋ().ˋ();
            this.ॱˋ = ((AppActivityProtocol) ʾ()).ˋ().ˎ();
        }
        super.onCreate(bundle);
        PermissionChecker.ˎ(this, 14);
        ˋ(this);
        if (0 == eua.ˏ().ॱ("client_first_launch_time", 0)) {
            eua.ˏ().ˎ("client_first_launch_time", System.currentTimeMillis());
        }
        dil.ˏ().ʼ();
        ActivityUtil.ॱ(true);
        ebi.add("horizonhomecard");
        ebi.add("horizontalapplistcard");
        ebi.add("horizonhomedlcard");
        ebi.add("horizonhomedlcardv2");
        ebi.add("horizontalsubstancecard");
        ebi.add("horizontalbilobacard");
        ebi.add("newentrancecard");
        ebi.add("smallhorizontalapplistcard");
        ebi.add("threeverticalappcard");
        ebi.add("twoleafgrasscard");
        ebi.add("multiplelineverticalcard");
        ebi.add("horizontalslidingcard");
        ebi.add("horizontalslidingdlcard");
        ebi.add("horizontalfixedcard");
        ebi.add("horizontalfixeddlcard");
        this.ˉ = new InteractiveRecommListenerImpl();
    }

    public void ˎ(String str, BaseCardBean baseCardBean, int i) {
        if (this.ˉ != null) {
            this.ˉ.ˎ(str, baseCardBean, i);
        }
    }

    public void ˋ(View view, int i) {
        if (this.ˉ != null) {
            this.ˉ.ˋ(view, i);
        }
    }

    public void ॱ(String str, cia o_cia, cvt o_cvt) {
        if (this.ˉ != null) {
            this.ˉ.ॱ(str, o_cia, o_cvt);
        }
    }

    public void ᐝ() {
        setContentView(R.layout.market_activity);
        this.tabHost = (FragmentTabHost) findViewById(16908306);
        this.ˏॱ = (ImageView) findViewById(R.id.skin_image);
        ᐨ();
    }

    public int ͺ() {
        return R.id.main_view_layout;
    }

    private void ᐨ() {
        this.mBottomNavigationView = (HwBottomNavigationView) findViewById(R.id.hiapp_mainscreen_bottomtab);
        wrapperNavigator(this.mBottomNavigationView);
        this.mColumnNavigator.setOnTabSelectedListener(this);
    }

    public void onDestroy() {
        dgm.setEnd(0);
        VideoNetChangeDialog.ˎ();
        super.onDestroy();
        ActivityUtil.unregisterReceiver((Context) this, this.ʾ);
    }

    public void excuteStateOfLogin(StartupResponse startupResponse) {
        if (euf.ˎ().ˏ()) {
            new cuh().ˏ();
        } else {
            Logger.ˏ("MarketActivity", "Push msg flag false!");
        }
        emw.ॱ();
        new enc().ˏ();
        if (UserSession.getInstance().getStatus() == 4) {
            Logger.ˎ("GLOBAL_START_FLOW", "MarketActivity, FLOW_END excuteStateOfLogin");
            eox.ˎ(ContentManager.getInstant().getContext(), false);
        }
        ᐝˊ();
    }

    private void ᐝˊ() {
        new dxe().ˊ();
    }

    public boolean onCreateOptionsMenu(Menu menu) {
        return super.onCreateOptionsMenu(menu);
    }

    public void onResume() {
        super.onResume();
        this.ʿ = dgh.ॱ();
        ˏˎ();
    }

    public void onPause() {
        super.onPause();
        dgh.ˋ(this, "990403", this.ʿ);
    }

    public TaskFragment ॱˊ() {
        return new AppCenterStartUpLoadingFragment();
    }

    public void ˎ(boolean z) {
        super.ˎ(z);
        dgh.ˊ();
    }

    public boolean ˋ(TaskFragment taskFragment, StartupResponse startupResponse) {
        if (!(taskFragment instanceof AppCenterStartUpLoadingFragment)) {
            return false;
        }
        ((AppCenterStartUpLoadingFragment) taskFragment).ˎ(ˎ((ResponseBean) startupResponse), true);
        return true;
    }

    public void ॱ(TaskFragment taskFragment) {
        if (taskFragment instanceof AppCenterStartUpLoadingFragment) {
            ((AppCenterStartUpLoadingFragment) taskFragment).ˎ(0, false);
        }
    }

    public int ᐝॱ() {
        return R.id.mainwindows_layout;
    }

    public void doubleExist() {
        evk.ˏ(this, R.string.touch_again_exit_appmarket, 0).ˋ();
        ActivityUtil.ॱ(false);
    }

    @TargetApi(23)
    public void onRequestPermissionsResult(int i, @NonNull String[] strArr, @NonNull int[] iArr) {
        if (14 == i && iArr.length != 0) {
            PermissionChecker.ˎ(this, i, strArr, iArr);
        }
    }

    public void ˏ(int i, int i2) {
        if (i2 == -1) {
            ᐝˋ();
        }
    }

    @TargetApi(24)
    private void ᐝˋ() {
        boolean shouldShowRequestPermissionRationale = shouldShowRequestPermissionRationale("android.permission.READ_PHONE_STATE");
        if (this.mNetWorkUtils == null) {
            this.mNetWorkUtils = new NetWorkUtls();
        }
        this.mNetWorkUtils.showDial(this, shouldShowRequestPermissionRationale, ˊˊ(), 14);
    }

    protected int ˊˊ() {
        return R.string.permission_deviceid_content;
    }

    private void ˋ(Activity activity) {
        this.ʾ = new CommonActivityReceiver();
        IntentFilter intentFilter = new IntentFilter();
        intentFilter.addAction("com.huawei.hwid.ACTION_REMOVE_ACCOUNT");
        ActivityUtil.registerReceiver(activity, intentFilter, this.ʾ);
    }

    public void ˏ(dji o_dji, ckm o_ckm) {
        if ("customColumn.managercenter".equals(cju.ˋ(o_ckm.ˊ()))) {
            djp.ˎ().ॱ(true);
            o_dji.ˊ(false);
            o_ckm.ˎ(false);
        } else if (dji.ˎ().equals(cju.ˋ(o_ckm.ˊ()))) {
            djp.ˎ().ˋ(true);
            o_dji.ˊ(false);
            o_ckm.ˎ(false);
        }
    }

    private void ꜟ() {
        dmq.ˏ.ˋ(new dmr(dmp.CONCURRENT, dmn.NORMAL, new e()));
    }

    public void ˎ(StartupResponse startupResponse, int i) {
        Logger.ˎ("MarketActivity", " not support service");
        CountryInfo ʻ = startupResponse.ʻ();
        if (ʻ != null) {
            List ˋ = ʻ.ˋ();
            if (CollectCheck.isEmpty(ˋ)) {
                Logger.e("MarketActivity", " countryList is empty.");
            } else {
                dzu.ॱ(ˋ, i);
            }
        } else {
            Logger.e("MarketActivity", " countryInfo is empty.");
        }
        ˊ(this, null);
        finish();
    }

    private void ˊ(Context context, String str) {
        cjo serviceZoneSwitchActivityProtocol = new ServiceZoneSwitchActivityProtocol();
        serviceZoneSwitchActivityProtocol.ॱ(new Request());
        serviceZoneSwitchActivityProtocol.ॱ().ˋ(str);
        cjm o_cjm = new cjm("servicezoneswitch.activity", serviceZoneSwitchActivityProtocol);
        o_cjm.ॱ().setFlags(268435456);
        cjk.ˎ().ˋ(context, o_cjm);
    }

    public boolean ˋ(TaskFragment taskFragment, b bVar) {
        boolean ˋ = super.ˋ(taskFragment, bVar);
        StartupResponse startupResponse = (StartupResponse) bVar.ˋ;
        if (ˋ && startupResponse.getResponseType() != a.FROM_CACHE) {
            ꜟ();
        }
        dzt.ˎ();
        return ˋ;
    }

    public void ˉ() {
        int size = RoamDataManager.build().getAppInfoBean().size();
        if (size >= 3) {
            String ॱ = eua.ˏ().ॱ("physical_address", "");
            long ॱ2 = eua.ˏ().ॱ("roam_time", 0);
            Logger.ˎ("MarketActivity", "showRoamPage address=" + ॱ + " roamTime=" + ॱ2);
            if (!dof.ˋ(ॱ) && ॱ2 != 0) {
                int ॱ3 = eua.ˏ().ॱ(ॱ + ॱ2, 0);
                Logger.ˎ("MarketActivity", "roam page isShow=" + ॱ3);
                if (ॱ3 == 0) {
                    RoamActivity.ˏ(this);
                    eua.ˏ().ˊ(ॱ + ॱ2, 1);
                    return;
                }
                return;
            }
            return;
        }
        Logger.e("MarketActivity", "roam data less 3, dataSize = " + size);
    }

    public void forceLogin() {
        eoj.ˋ().ˎ("forceLogin", this.mAccountListener);
        eod.ॱ(getApplicationContext());
    }

    public void ˊॱ() {
        eod.ˋ(this, true, true);
        dte.ˋ();
    }
}
